<?php
class Jnd_Db_Select_Mysql extends Zend_Db_Select
{

    const SQL_CALC_FOUND_ROWS = 'sqlCalcFoundRows';
    // add other options as needed
    public function __construct( Zend_Db_Adapter_Abstract $adapter )
    {
        /**
         * Use array_merge() instead of simply setting a key
         * because the order of keys is significant to the
         * rendering of the query.
         */
        $partsInit = self::$_partsInit;
        $persoPartsInit = array(
            self::SQL_CALC_FOUND_ROWS => false
        );
        $parts = array_merge($persoPartsInit, $partsInit);
        self::$_partsInit = $parts;
        parent::__construct($adapter);
    }

    public function sqlCalcFoundRows( $flag = true )
    {
        $this->_parts[self::SQL_CALC_FOUND_ROWS] = (bool) $flag;
        return $this;
    }

    protected function _renderSqlCalcFoundRows( $sql )
    {
        if ($this->_parts[self::SQL_CALC_FOUND_ROWS]) {
            $sql .= ' SQL_CALC_FOUND_ROWS';
        }
        
        return $sql;
    }
}